package com.ruoyi.web.controller.ies;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ies.domain.Orientation;
import com.ruoyi.ies.service.IOrientationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 定位打卡Controller
 *
 * @author July
 * @date 2023-06-08
 */
@RestController
@RequestMapping("/ies/orientation")
public class OrientationController extends BaseController
{
    @Autowired
    private IOrientationService orientationService;

    /**
     * 查询定位打卡列表
     */
    @PreAuthorize("@ss.hasPermi('ies:orientation:list')")
    @GetMapping("/list")
    public TableDataInfo list(Orientation orientation)
    {
        startPage();
        List<Orientation> list = orientationService.selectOrientationList(orientation);
        return getDataTable(list);
    }

    /**
     * 导出定位打卡列表
     */
    @PreAuthorize("@ss.hasPermi('ies:orientation:export')")
    @Log(title = "定位打卡", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Orientation orientation)
    {
        List<Orientation> list = orientationService.selectOrientationList(orientation);
        ExcelUtil<Orientation> util = new ExcelUtil<Orientation>(Orientation.class);
        util.exportExcel(response, list, "定位打卡数据");
    }

    /**
     * 获取定位打卡详细信息
     */
    @PreAuthorize("@ss.hasPermi('ies:orientation:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(orientationService.selectOrientationById(id));
    }

    /**
     * 新增定位打卡
     */
    @PreAuthorize("@ss.hasPermi('ies:orientation:add')")
    @Log(title = "定位打卡", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Orientation orientation)
    {
        return toAjax(orientationService.insertOrientation(orientation));
    }

    /**
     * 修改定位打卡
     */
    @PreAuthorize("@ss.hasPermi('ies:orientation:edit')")
    @Log(title = "定位打卡", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Orientation orientation)
    {
        return toAjax(orientationService.updateOrientation(orientation));
    }

    /**
     * 删除定位打卡
     */
    @PreAuthorize("@ss.hasPermi('ies:orientation:remove')")
    @Log(title = "定位打卡", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(orientationService.deleteOrientationByIds(ids));
    }
}
